Skip to content

feat(document): add --title-from-filename flag#56

Open
geopanther wants to merge 1 commit into
mainfrom
feat/title-from-filename
Open

feat(document): add --title-from-filename flag#56
geopanther wants to merge 1 commit into
mainfrom
feat/title-from-filename

Conversation

@geopanther

Copy link
Copy Markdown
Owner

Summary

Add --title-from-filename flag to always use the filename as the page title, overriding any title found in document headers or front matter. Useful when multiple markdown files share the same top-level heading but need distinct Confluence page titles.

Adapted from iamjackg/md2cf#115 by @devzeb.

Changes

  • New CLI flag --title-from-filename (mutually exclusive with --title)
  • Error when used with stdin input
  • Thread page_title_from_filename through get_pages_from_directory() and get_page_data_from_file_path()
  • Filename stem used as title when flag is set, regardless of document content

Tests

  • 4 new tests in test_document_title.py covering all combinations
  • All 26 document tests pass

Add option to always use the filename as the page title, overriding
any title found in the document header or front matter. Useful when
multiple files share the same top-level heading but need distinct
Confluence page titles.

Mutually exclusive with --title. Errors when used with stdin input.

Adapted from iamjackg/md2cf#115 by @devzeb.
@geopanther

Copy link
Copy Markdown
Owner Author

Maintainer Review

Verdict: ✅ Approve with minor suggestion

Clean, well-scoped feature that addresses a real pain point — when documents share headings like "Overview" or "Introduction" but need unique Confluence titles.

Good:

  • Mutually exclusive with --title via argparse group — prevents ambiguity
  • Properly guards against stdin usage
  • Threaded through both directory and single-file code paths
  • Good test coverage for all title source combinations

Suggestion:

  • Consider adding README documentation for the flag (non-blocking)
  • The flag name matches the upstream convention, which is good for discoverability

Note on upstream PR: The original md2cf PR also included an argument parser test file (test_argument_parser.py). I opted to keep tests in test_document_title.py only since the mutually exclusive group behavior is already tested by argparse itself.

No blocking concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant